<template>
    <div class="father2">
        祖父传给孙子的钱：{{money}} <br>
        祖父传给孙子的车名字：{{immovableVar.name}}，车贷款：{{immovableVar.loans}}
        <button @click="changeMoney(8)">孙子花爷爷的钱</button>
    </div>
</template>
<script setup   lang="ts">
import {ref,inject} from 'vue'
let {money,changeMoney} = inject('propertyContext',{money:0,changeMoney:(val:number)=>{}})//★
//通过{name:'',loans:''}默认值实现ts推断
let immovableVar = inject('immovable',{name:'',loans:''}) 
</script>
<style scoped>
.father2{
    width: 30vw;
    height: 30vh;
    background-color: rgb(242, 186, 67);
}
</style>
